﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:my="clr-namespace:Q2Q.UI.Controls"
	>

	<Style x:Key="FSC" TargetType="FrameworkElement">
		<Setter Property="WindowChrome.CaptionHeight" Value="0" />
	</Style>
	
	<Style x:Key="CustomWindowStyle" TargetType="Window">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Window">
					<Border x:Name="WindowBorder" BorderThickness="0">
						<Grid x:Name="WindowGrid" Background="{TemplateBinding Background}">
							<Grid.RowDefinitions>
								<RowDefinition x:Name="R1" Height="28" />
								<RowDefinition Height="*" />
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="Auto" />
							</Grid.ColumnDefinitions>
							<!--<Border BorderThickness="0,0,0,1" Grid.Column="0" Grid.ColumnSpan="3" BorderBrush="DarkGray" />-->
							<Image Grid.Column="0" Source="{TemplateBinding Icon}" MaxWidth="24" MaxHeight="24" Margin="4,4,8,4" x:Name="Icon" WindowChrome.IsHitTestVisibleInChrome="True" VerticalAlignment="Center" />
							<TextBlock x:Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" HorizontalAlignment="Stretch" FontSize="16" Foreground="{DynamicResource WindowTitleForegroundInactiveColorBrush}" FontFamily="Segoe UI Light" VerticalAlignment="Center" Margin="0,0,6,0" TextTrimming="CharacterEllipsis" />

							<my:WindowSystemButtons Grid.Column="2" Foreground="{DynamicResource ForegroundColorBrush}" x:Name="SystemButtons" Margin="0,0,0,0" VerticalAlignment="Stretch" ResizeMode="{TemplateBinding ResizeMode}" HorizontalAlignment="Right" WindowChrome.IsHitTestVisibleInChrome="True" WindowState="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=WindowState, Mode=TwoWay}" />

							<ContentPresenter x:Name="CP" Grid.Row="1" Grid.ColumnSpan="3" Margin="0" />

						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="WindowState" Value="Maximized">
							<Setter Property="Height" Value="32" TargetName="R1" />
							<Setter Property="Margin" Value="0,4,6,0" TargetName="Title" />
							<Setter Property="Margin" Value="10,10,8,2" TargetName="Icon" />
							<Setter Property="Margin" Value="8,0,8,8" TargetName="CP" />
							<Setter Property="Margin" Value="0,8,8,0" TargetName="SystemButtons" />
						</Trigger>
						<Trigger Property="WindowState" Value="Normal">
							<Setter Property="BorderThickness" Value="1" TargetName="WindowBorder" />
							<Setter Property="BorderBrush" Value="{DynamicResource WindowBorderBrush}" TargetName="WindowBorder" />
						</Trigger>
						<Trigger Property="IsActive" Value="True">
							<Setter Property="Foreground" Value="{DynamicResource WindowTitleForegroundColorBrush}" TargetName="Title" />
						</Trigger>
						<Trigger Property="WindowStyle" Value="None">
							<Setter Property="Visibility" Value="Collapsed" TargetName="Title" />
							<Setter Property="Visibility" Value="Collapsed" TargetName="Icon" />
							<Setter Property="Visibility" Value="Collapsed" TargetName="SystemButtons" />
							<Setter Property="Height" Value="8" TargetName="R1" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="Background" Value="{DynamicResource WindowColorBrush}" />
		<Setter Property="WindowChrome.WindowChrome">
			<Setter.Value>
				<WindowChrome x:Name="Chrome" CaptionHeight="22" ResizeBorderThickness="8" GlassFrameThickness="0" CornerRadius="0"/>
			</Setter.Value>
		</Setter>
		<Style.Triggers>
			<Trigger Property="WindowStyle" Value="None">
				<!--<Setter Property="Height" Value="6" TargetName="R1" />-->
				<!--<Setter Property="WindowChrome.WindowChrome" Value="{x:Null}" />-->
				<Setter Property="WindowChrome.WindowChrome">
					<Setter.Value>
						<WindowChrome CaptionHeight="1"/>
					</Setter.Value>
				</Setter>
				<Setter Property="Topmost" Value="True" />
				<Setter Property="WindowState" Value="Maximized" />
 				<!--<Setter Property="Visibility" Value="Hidden" TargetName="Title" />
							<Setter Property="Visibility" Value="Hidden" TargetName="Icon" />
							<Setter Property="Visibility" Value="Hidden" TargetName="SystemButtons" />-->
			</Trigger>
		</Style.Triggers>
	</Style>

</ResourceDictionary>
